//package com.yunhe.option.controller.data;
//
//import com.yunhe.common.model.DomainList;
//import com.yunhe.option.domain.data.Weather;
//import com.yunhe.common.exception.ArgumentErrorException;
//import com.yunhe.common.exception.UniqueConstraintsException;
//import com.yunhe.common.model.PageParam;
//import com.yunhe.common.model.ResultObject;
//import com.yunhe.option.service.data.WeatherService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.format.annotation.DateTimeFormat;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.Date;
//import java.util.List;
//import java.util.Optional;
//
///**
// * 气候Controller
// * @author liuronglei
// * @desc 气候控制类定义
// */
//@Api(value = "weather", description = "气候状态维护", tags = {"Data_Weather"})
//@RestController
//@RequestMapping("/weathers")
//public class WeatherController {
//    @Autowired
//    private WeatherService weatherService;
//
//    /**
//     * 新增气候状态
//     * @param weather 气候状态对象
//     */
//    @ApiOperation("新增气候状态")
//    @RequestMapping(method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(
//            @RequestBody Weather weather)
//            throws ArgumentErrorException, UniqueConstraintsException {
//        Weather newWeather = weatherService.createWeather(weather);
//        return new ResponseEntity<>(new ResultObject<>(newWeather), HttpStatus.OK);
//    }
//
//    /**
//     * 批量新增气候状态
//     * @param list 气候状态对象
//     */
//    @ApiOperation("批量新增气候状态")
//    @RequestMapping(value = "/batch", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(
//            @RequestBody DomainList<Weather> list)
//            throws ArgumentErrorException, UniqueConstraintsException {
//        Iterable<Weather> newWeathers = weatherService.createWeather(list.getList());
//        return new ResponseEntity<>(new ResultObject<>(newWeathers), HttpStatus.OK);
//    }
//
//    /**
//     * 根据条件获得气候状态列表
//     * @param areaCode 地区代码
//     * @param dtime 时间范围
//     */
//    @ApiOperation("根据条件获得气候状态列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "areaCode", value = "地区代码", required = true, dataType = "Long", paramType = "query"),
//            @ApiImplicitParam(name = "dtime", value = "时间范围，如“2017-12-06 00:00:00,2017-12-06 23:45:00”", dataType = "Date", paramType = "query")
//    })
//    @RequestMapping(method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search(
//            @RequestParam("areaCode") Optional<Long> areaCode,
//            @RequestParam("dtime") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Optional<List<Date>> dtime,
//            @ModelAttribute PageParam pageParam) {
//        Iterable<Weather> results = weatherService.findWeathers(areaCode.orElse(null), dtime.orElse(null), pageParam);
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//}